package cn.ecnu.pojo;

import cn.ecnu.util.TimestampDeserializer;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Set;

@Entity
@Table(name = "conference")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "会议实体类")
public class Conference implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @TableId(type = IdType.AUTO)
    @Column(name = "conference_id")
    @ApiModelProperty(value = "会议ID", example = "1")
    private Integer conferenceId;

    @Column(name = "title", nullable = false)
    @ApiModelProperty(value = "会议标题", required = true, example = "International Conference on AI")
    private String title;

    @ApiModelProperty(value = "Short name of the conference")
    @Column(name = "short_name")
    private String shortName;

    @Column(name = "description")
    @ApiModelProperty(value = "会议描述", example = "This is a conference about AI.")
    private String description;

    @Column(name = "location")
    @ApiModelProperty(value = "会议地点", example = "New York")
    private String location;

    @ElementCollection(targetClass = String.class)
    @CollectionTable(name = "conference_categories", joinColumns = @JoinColumn(name = "conference_id"))
    @Column(name = "categories")
    @ApiModelProperty(value = "会议类别", example = "[\"Artificial Intelligence\", \"Machine Learning\"]")
    private Set<String> categories;

    @Column(name = "ccf_level", nullable = false)
    @ApiModelProperty(value = "CCF分级", required = true, example = "A")
    private String ccfLevel;

    @Column(name = "start_date")
    @ApiModelProperty(value = "会议开始日期", example = "2024-06-17")
    private Date startDate;

    @Column(name = "end_date")
    @ApiModelProperty(value = "会议结束日期", example = "2024-06-17")
    private Date endDate;

    @Column(name = "submission_deadline")
    @ApiModelProperty(value = "提交截止日期", example = "2024-06-17")
    private Date submissionDeadline;

    @Column(name = "notification_date")
    @ApiModelProperty(value = "通知日期", example = "2024-06-17")
    private Date notificationDate;

    @Column(name = "conference_url")
    @ApiModelProperty(value = "会议网址", example = "http://www.example.com")
    private String conferenceUrl;

    @Column(name = "views", nullable = false, columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(value = "浏览数", required = true, example = "100")
    private int views;

    @Column(name = "follows", nullable = false, columnDefinition = "INT DEFAULT 0")
    @ApiModelProperty(value = "关注数", required = true, example = "50")
    private int follows;

    @Column(name = "created_at", nullable = false, updatable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "创建时间", required = true, example = "2024-06-11 06:40:56")
    private Date createdAt;

    @Column(name = "updated_at", nullable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    @ApiModelProperty(value = "更新时间", required = true, example = "2024-06-11 06:40:56")
    private Date updatedAt;
}
